package com.zzh.zzhaiagent.controller;

import com.zzh.zzhaiagent.protection.rate.RateLimiter;
import com.zzh.zzhaiagent.protection.rate.resolver.ClientIpRateLimiterKeyResolver;
import com.zzh.zzhaiagent.protection.utils.IpGetUtil;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: zzh
 * @date: 2025/06/12 17:01:20
 * @version: 1.0
 * 测试IP请求验证
 */
@RestController
@RequestMapping("ip")
@Tag(name = "IP测试")
public class IPController {
    @RequestMapping("test")
    @RateLimiter(keyResolver = ClientIpRateLimiterKeyResolver.class,
            count = 10, //10s内访问10次
            time = 10)
    public String test() {
        return IpGetUtil.getClientIP();
    }
}
